<?php

namespace Dengje\OnlineUpdate\Http\Controllers;

use App\Admin\Actions\Grid\AuthenticationAction;
use App\Admin\Repositories\WxAuthentication;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Admin;
use Dengje\OnlineUpdate\Http\Repositories\Version;
use Illuminate\Routing\Controller;


class OnlineUpdateController extends Controller
{
    public function index(Content $content)
    {
        $versionData = [1,2,3,4,1,4,5,5,5,6,6,1,6,6];

        return $content
            ->title('更新')
            ->description('当前版本v1.0.0')
            ->body($this->versionData());
    }


    public function versionData(){
    return Grid::make(new Version(), function (Grid $grid) {
        $grid->model()->orderBy('id','desc');
        $grid->column('version','版本号');
        $grid->column('name','程序');
        $grid->column('description','描述')->limit(12);

        $grid->column('created_at');
        $grid->column('active')->display(function ($v){
           return '<a href="online-update/download" >更新该版本</a>';
        });

        $grid->filter(function (Grid\Filter $filter) {
            $filter->equal('id');

        });


        $grid->actions(function (Grid\Displayers\Actions $actions) {
            $actions->disableDelete();
            $actions->disableEdit();
            $actions->disableQuickEdit();
            $actions->disableView();
        });

    });
    }


    public function download(Content $content)
    {


        return $content
            ->title('更新')
            ->description('当前版本v1.0.0')
            ->body(admin::view('dengje.online-update::download'));

    }
}
